package com.holyant.goods.dto;

import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.utils.StringUtils;
import com.holyant.goods.enums.GdsSkuPurchasePriceCurTypeEnum;
import com.holyant.goods.enums.QuotMethodEnum;
import com.holyant.goods.enums.QuoteSalesChannel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import java.math.BigDecimal;
import java.util.Objects;


/** 商品结算价共用导入类
 * @author zgx *
 * @date 2022年07月18日 15:06
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ToString(callSuper = true)
public class GdsSkuQuotePublicImportDto  extends PriceImportBase{



    @Excel(name = "渠道类型",prompt="C2P/POP/B2B-CN/B2B-HK/B2B-MO/KA/WM-C/WM-B",sort = 1)
    private String salesChannel;
    private Integer salesChannelVal;





    @ApiModelProperty(hidden = true,name = "skuId")
    private Long skuId;





    public Integer getSalesChannelVal() {
        if (StringUtils.isEmpty(this.salesChannel))return null;
        return QuoteSalesChannel.getCodeByName(this.salesChannel);
    }

    @Override
    public Integer getCurTypeVal() {
        if (StringUtils.isEmpty(super.curType)) return null;
        return GdsSkuPurchasePriceCurTypeEnum.getCodeByName(super.curType);
    }

    @Override
    public Integer getQuoteMethodVal() {
        if (StringUtils.isEmpty(super.quoteMethod)) return null;
        return QuotMethodEnum.getCodeByName(super.quoteMethod);
    }




   @Override
    public String getPcs1() {
        if (StringUtils.isNotBlank(super.pcs1)) {
            return new BigDecimal(super.pcs1).setScale(4, BigDecimal.ROUND_HALF_UP).toString();
        }
        return super.pcs1;
    }

    @Override
    public String getPcs2() {
        if (StringUtils.isNotBlank(super.pcs2)) {
            return new BigDecimal(super.pcs2).setScale(4, BigDecimal.ROUND_HALF_UP).toString();
        }
        return super.pcs2;
    }
    @Override
    public String getPcs3() {
        if (StringUtils.isNotBlank(super.pcs3)) {
            return new BigDecimal(super.pcs3).setScale(4, BigDecimal.ROUND_HALF_UP).toString();
        }
        return super.pcs3;
    }
    @Override
    public String getPcs4() {
        if (StringUtils.isNotBlank(super.pcs4)) {
            return new BigDecimal(super.pcs4).setScale(4, BigDecimal.ROUND_HALF_UP).toString();
        }
        return super.pcs4;
    }
    @Override
    public String getPcs5() {
        if (StringUtils.isNotBlank(this.pcs5)) {
            return new BigDecimal(this.pcs5).setScale(4, BigDecimal.ROUND_HALF_UP).toString();
        }
        return this.pcs5;
    }
    @Override
    public String getPcs6() {
        if (StringUtils.isNotBlank(super.pcs6)) {
            return new BigDecimal(super.pcs6).setScale(4, BigDecimal.ROUND_HALF_UP).toString();
        }
        return super.pcs6;
    }
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        GdsSkuQuotePublicImportDto that = (GdsSkuQuotePublicImportDto) o;
        return Objects.equals(this.getSkuCode(), that.getSkuCode()) && Objects.equals(this.getCurType(), that.getCurType()) && Objects.equals(this.getQuoteMethod(), that.getQuoteMethod());
    }

    @Override
    public int hashCode() {
        return Objects.hash(this.getSkuCode(), this.getCurType(), this.getQuoteMethod());
    }
}
